import { Component, OnInit, Input } from '@angular/core';

import { AlertController } from '@ionic/angular';
import { ModalController } from '@ionic/angular';

import { HttpService } from 'src/app/shared/service/http.service';

import { ImgSlidePage } from '../slides-imgage/img-slide.page';

@Component({
    selector: 'app-contract-audit-detail',
    templateUrl: './contract-audit-detail.component.html',
    styleUrls: ['./contract-audit-detail.component.scss'],
})

export class ContractAuditDetailComponent implements OnInit {
    constructor(public alertController: AlertController, private modalCtrl: ModalController, private http: HttpService) { }
    @Input() tagData: any;
    data: any = [];
    // test: any = {
    //     "type": "tag",
    //     "style": "tag.contractAudit",
    //     "data": {
    //         "status": {
    //             "icon": "https://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_7ba55b58e1981e5b1f81392d9468e180.png"
    //         },
    //         "data": [
    //             {
    //                 "type": "normal",
    //                 "label": "信息编号",
    //                 "content": {
    //                     "display": "52356"
    //                 }
    //             },
    //             {
    //                 "type": "normal",
    //                 "label": "实收金额",
    //                 "content": {
    //                     "display": "<font color='red'>1000元</font> (合同金额2000元)"
    //                 }
    //             },
    //             {
    //                 "type": "contact",
    //                 "label": "业务归属",
    //                 "content": {
    //                     "name": "秋晓萌",
    //                     "mobile": "13568957845",
    //                     "section1": "<font color='red'>加盟</font>",
    //                     "section2": "西安业务部"
    //                 }
    //             },
    //             {
    //                 "type": "line"
    //             },
    //             {
    //                 "type": "advertise",
    //                 "label": "广告位",
    //                 "content": {
    //                     "display": "转店焦点广告，展示30天",
    //                     "payImages": [
    //                         "https://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_7ba55b58e1981e5b1f81392d9468e180.png",
    //                         "https://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_7ba55b58e1981e5b1f81392d9468e180.png"
    //                     ],
    //                     "contractImages": [
    //                         "https://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_7ba55b58e1981e5b1f81392d9468e180.png",
    //                         "http://cccc2.png"
    //                     ]
    //                 }
    //             }
    //         ]
    //     }
    // };
    ngOnInit() {
        // 赋值
        this.data = this.tagData.data;
    }
    // 打电话
    async callConsultant(e) {
        const alert = await this.alertController.create({
            header: '',
            subHeader: '',
            message: e,
            buttons: [{
                text: '取消',
                role: 'cancel',
                cssClass: 'secondary',
                handler: () => {
                    console.log('取消');
                }
            }, {
                text: '拨打',
                cssClass: 'LJ',
                handler: () => {
                    this.http.changeCallNumber(e);
                }
            }, ]
        });
        await alert.present();
    }
    // 图片放大
    async openImage_url(index, images) {
        const value = { img: images, index: index + 1 };
        const modal = await this.modalCtrl.create({
            component: ImgSlidePage,
            componentProps: { value: JSON.stringify(value) }
        });
        return await modal.present();
    }
}
